#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N],v[N],h[N];
double d[N],p[N],x[N];
vector<int>vec[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin>>T;
    while(T--){
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        memset(a,0,sizeof(a));
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(h,0,sizeof(h));
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]<0){
                x[i]=d[i]+v[i]*1.0/(0-a[i]);
            }
            else x[i]=L;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        /*for(int i=1;i<=n;i++){
            cout<<d[i]<<' '<<v[i]<<' '<<a[i]<<' '<<x[i]<<'\n';
        }*/
        memset(vec,0,sizeof(vec));
        int ans1=0;
        for(int i=1;i<=n;i++){
            //cout<<i<<':'<<'\n';
            for(int j=1;j<=m;j++){
                double v1;
                if(p[j]<d[i])v1=-1;
                else if(2*1.0*(p[j]-d[i])*a[i]+v[i]*v[i]*1.0<0)v1=-1;
                else v1=(double)sqrt(2*1.0*(p[j]-d[i])*a[i]+v[i]*v[i]*1.0);
                //cout<<v1<<' ';
                if(v1!=-1&&v1>V){
                    ans1++;
                    break;
                }
            }
            //cout<<'\n';
        }
        int ans2=0;
        /*for(int i=1;i<=n;i++){
            //cout<<i<<':'<<'\n';
            for(int j=1;j<=m;j++){
                double v1;
                if(p[j]<d[i])v1=-1;
                else if(2*1.0*(p[j]-d[i])*a[i]+v[i]*v[i]*1.0<0)v1=-1;
                else v1=(double)sqrt(2*1.0*(p[j]-d[i])*a[i]+v[i]*v[i]*1.0);
                //cout<<v1<<' ';
                if(v1!=-1&&v1>V){
                    cout<<j<<' ';
                }
            }
            cout<<'\n';
        }
        cout<<'\n';*/
        set<int>s1;
        for(int i=1;i<=m;i++){
            bool flag=true;
            for(int j=1;j<=n;j++){
                double v1;
                if(p[i]<d[j])v1=-1;
                else if(2*1.0*(p[i]-d[j])*a[j]+v[j]*v[j]*1.0<0)v1=-1;
                else v1=(double)sqrt(2*1.0*(p[i]-d[j])*a[j]+v[j]*v[j]*1.0);
                if(v1!=-1&&v1>V){
                   //cout<<j<<' ';
                   vec[i].push_back(j);
                   s1.insert(j);
                }
            }
            //cout<<'\n';
        }
        /*for(int i=1;i<=m;i++){
            for(int j=0;j<vec[i].size();j++){
                cout<<vec[i][j]<<' ';
            }
            cout<<'\n';
        }
        cout<<"\n";*/
        int t=0;
        set<int>s;
        while(s.size()<s1.size()){
            int x,maxn=0;
            for(int i=1;i<=m;i++){
                int cnt=0;
                for(int j=0;j<vec[i].size();j++){
                    if(h[vec[i][j]]==0){
                        cnt++;
                    }
                }
                if(cnt>maxn){
                    maxn=cnt;
                    x=i;
                }
            }
            bool flag=false;
            for(int i=0;i<vec[x].size();i++){
                if(h[vec[x][i]]==0){
                    h[vec[x][i]]=1;
                    s.insert(vec[x][i]);
                    flag=true;
                }
            }
            if(flag==true){
                t++;
                //cout<<"x:"<<x<<'\n';
            }
        }
        cout<<ans1<<' '<<m-t<<'\n';
        //cout<<'\n';
    }
    return 0;
}